<?php

	// Session
	session_start();
	
	// Nese vizitori eshte i identifikuar
	if (!isset($_SESSION['user_id'])) {
		header("Location: login.php");
	}
	
	// Nese identifikatori i librit nuk eshte definuar
	if (!isset($_GET['id'])) {
		header("Location: books.php");
	}
	
	// Integrimi i skedave sistemore
    include('../include/functions.inc.php');
	include('../include/template.class.php');
	
	// Project
	$PROJECT = setProject();
	
	
	// Ndyshoret primare
	define('TPL','../include/styles/'.$PROJECT['style'].'/members/visits.html');
	define('ID',$_GET['id']);
	define('UID',$_SESSION['user_id']);
	define('FILENAME',basename($_SERVER["PHP_SELF"]));
	
	
	// Connection
	dbOpen("comunity");
	
	
	// Inicializimi i shablonave
	$tmp = new Template(TPL,$PROJECT['lang']);
	
	
	// INDEXING OPTIONS
	$INDEX['sid'] = indexing("SELECT id, name FROM sections");
	$INDEX['access'] = $tmp->indexing("access");
	
	
	// MENUES
	$tmp->setContent("CATEGORY",$tmp->menu("category","../members"));
	$tmp->setContent("MYMENU",$tmp->menu("mymenu","books.php"));
	$tmp->setContent("FOOTMENU",$tmp->menu("foot"));
	$tmp->setContent("MYBOOK",$tmp->menu("mybook",FILENAME,'?id='.ID));
	
	
	// InfoBook
	$BOOK = infoBook(ID,$INDEX);
	$tmp->setContent("INFOBOOK",$BOOK);
	
	
	// How to Drop Comments
	$tmp->setContent("HELP",$tmp->xmlContent("visit","help.xml"));
	
	
	// Krijo fushen per treguesin e vizitueshmeris, formati [TIMESTAMP,DAY_HITS]
	$BOOK['visitBars'] = visitBars(implode(mysql_fetch_assoc(mysql_query("SELECT counter FROM contents WHERE book_id = '".ID."'"))));
	$tmp->setContent($BOOK);
	
	// LABELS
	$tmp->setLabels();
	
	// Dhe cdo gje ka nje fund, trego faqen						  
	echo $tmp->vorlage;

?>